import React from "react";
import { 
    NavigationContainer,
    getFocusedRouteNameFromRoute, 
    Route,
 } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';

import BottomTabs from "./BottomTabs";

/** 登录页面 */
import LoginView from "../views/login/LoginView";
import RegisterView from "../views/login/RegisterView";
import ResetPasswordView from "../views/login/ResetPasswordView";

/** 功能页面 */
import EnrollmentView from "../views/home/EnrollmentView";
import InvitationAddView from "../views/home/InvitationAddView";
import InvitationEditView from "../views/home/InvitationEditView";


/**
 * 页面路由页面
 */
const PageRoutes = () => {
    const Stack = createNativeStackNavigator();


    /// 设置名字
function getHeaderTitle(route) {
    // 获取路由名字
    const routeName = getFocusedRouteNameFromRoute(route) ?? 'Extract';

    switch (routeName) {
        case 'Home':
            return '首页';
        case 'Message':
            return '消息';
        case 'MineView':
            return '我';
    }
}

    return (
        <NavigationContainer>                    
            <Stack.Navigator
                screenOptions={{
                    // headerShown: false,
                    headerTintColor: '#FFFFFF', // 标题颜色
                    headerBackTitleVisible: false, // 返回按键文字不可见
                    headerStyle: {
                        backgroundColor: '#01246E',
                    }
                }}
            >

                <Stack.Group name="Mine">
                    <Stack.Screen name="LoginView" component={LoginView} options={{ title: '登录' }}></Stack.Screen>
                    <Stack.Screen name="RegisterView" component={RegisterView} options={{ title: '注册' }}></Stack.Screen>
                    <Stack.Screen name="ResetPasswordView" component={ResetPasswordView} options={{ title: '重置密码' }}></Stack.Screen>

                </Stack.Group>

                <Stack.Screen
                    name="BottomTabs"
                    component={BottomTabs}
                    options={({ route }) => ({                                                
                        headerShown: false, // 隐藏
                        headerTitle: getHeaderTitle(route),
                        headerStyle: {                        
                            // backgroundColor: '#01246E',
                        },
                    })}
                ></Stack.Screen>


                <Stack.Group name="Message">
                    <Stack.Screen name="EnrollmentView" component={EnrollmentView} options={{ title: '入职登记' }}></Stack.Screen>
                    <Stack.Screen name="InvitationAddView" component={InvitationAddView} options={{ title: '邀约登记' }}></Stack.Screen>
                    <Stack.Screen name="InvitationEditView" component={InvitationEditView} options={{ title: '邀约编辑' }}></Stack.Screen>
                </Stack.Group>
                

                <Stack.Group name="Message">
                    {/* <Stack.Screen name="CulturalCreativeMarketView" component={CulturalCreativeMarketView} options={{ title: '文创市集' }}></Stack.Screen>
                    <Stack.Screen name="MyCreateCenterView" component={MyCreateCenterView} options={{ title: '我的创作中心' }}></Stack.Screen>
                    <Stack.Screen name="MyBooksView" component={MyBooksView} options={{ title: '关于' }}></Stack.Screen> */}
                </Stack.Group>

                {/* 我的 */}
                <Stack.Group name="Mine">
                    {/* <Stack.Screen name="MyHomePageView" component={MyHomePageView} options={{ title: '我的主页' }}></Stack.Screen>
                    <Stack.Screen name="MyCardView" component={MyCardView} options={{ title: '我的卡片' }}></Stack.Screen>
                    <Stack.Screen name="FollowView" component={FollowView} options={{ title: '关注' }}></Stack.Screen>
                    <Stack.Screen name="CollectView" component={CollectView} options={{ title: '收藏' }}></Stack.Screen>
                    <Stack.Screen name="PoetryListView" component={PoetryListView} options={{ title: '诗单' }}></Stack.Screen>
                    <Stack.Screen name="StudyPlanView" component={StudyPlanView} options={{ title: '学习计划' }}></Stack.Screen>
                    <Stack.Screen name="MemberCenterView" component={MemberCenterView} options={{ title: '会员中心' }}></Stack.Screen>
                    <Stack.Screen name="MyWalletView" component={MyWalletView} options={{ title: '我的钱包' }}></Stack.Screen>
                    <Stack.Screen name="MessageNoticeView" component={MessageNoticeView} options={{ title: '消息通知' }}></Stack.Screen>

                    <Stack.Screen name="AboutUsView" component={AboutUsView} options={{ title: '关于我们' }}></Stack.Screen> */}

                </Stack.Group>
                
            </Stack.Navigator>
        </NavigationContainer>
    )
}

export default PageRoutes;